<?php
namespace Home\Controller;

use Common\Logic\GoodsLogic;
use Think\Controller;

class IndexController extends Controller
{
    public function index()
    {

        $system_type = '';
        $param = '';
        foreach ( $_GET as $k => $v )
            $param .= '&'.$k.'='.$v;
        //微信端打开
        if(strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false){

            $system_type = 'WeChat';

            //如果没带id参数,跳转到微商城首页
            if( !isset($_GET['id']) ){

                header('Location: '.C('WeChat_Root'));

            //如果带id参数,跳转到微商城商品详情页面
            } else {

                header('Location: '.C('WeChat_Root').'/html/product.detail.html?'.$param);

            }
        //Android系统打开
        }else if(strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false){

            $system_type = 'Android';
        //IOS手机打开
        } else if(strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== false){

            $system_type = 'IOS';

        } else {

            include T('go_wechat');
            exit;

        }

        //如果是分销商品,记录分销商品的点击次数
        if( I('get.ally') == 1 )
        {

            $distribution_logic = D('Common/Distribution','Logic');

            $distribution_logic::$model
                            ->where(['goods_id' => I('get.id'),'uid' => I('get.uid')])
                            ->setInc('click_nums',1);

        }



        include T();
    }
}